﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Pseudogenerator.Common.Generators.Core;

namespace Pseudogenerator.Common.Generators
{
   public class TwoSetsMix : Mix
    {


        private Green _g2;
        protected Green Serie2
        {
            get
            {
                if (_g2 == null)
                    _g2 = new Green() { m = this.m, k = this.k };

                return _g2;
            }
            set
            {
                this._g2 = value;
            }
        }

       public override bool CanGenerateNext
       {
           get { return m > k && k > 16; }
       }

       public override uint GetNextValue()
       {
           throw new NotImplementedException();
       }


       public override List<RandomNumber> GetFullList()
       {
           var nums = new List<RandomNumber>();
           if (CanGenerateNext)
           {
               var numsSer1 = new List<RandomNumber>(Serie1.GetFullList());
               var numsSer2 = new List<RandomNumber>(Serie2.GetFullList());
               var vector = new List<RandomNumber>();
               for (int i = 0; i < k; i++)
               {
                   vector.Add(numsSer2[i]);
               }
               for (int i = 0; i < m; i++)
               {
                   int j = (int)(k * numsSer1[i].Uniform);
                   nums.Add(new RandomNumber(m) { n = (uint)i, Xn = numsSer1[j].Xn });
               }
           }
           return nums;

       }

       public override string ToString()
       {
           return string.Format("k = {0}, m = {1}", k, m);
       }

    }
}
